package com.sky.controller.admin;

import com.sky.config.RedisConfiguration;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/shop")
@Slf4j
@ApiOperation(value = "店铺管理页面")
public class ShopController {

    @Autowired
    public RedisTemplate redisTemplate;

    @ApiOperation(value = "店铺状态修改")
    @PutMapping("/{status}")
    public Result<String> updateStatus(@PathVariable Integer status) {
        log.info("店铺状态修改为:{}", status == 1? "营业中" : "打烊了");
        redisTemplate.opsForValue().set("SHOP_STATUS", status);

        return Result.success();
    }


    @ApiOperation(value = "获取店铺状态")
    @GetMapping("/status")
    public Result<Integer> getStatus() {
        Integer status = (Integer) redisTemplate.opsForValue().get("SHOP_STATUS");
        log.info("获取到店铺状态为:{}", status == 1? "营业中" : "打烊了");
        return Result.success(status);
    }
}
